<!--
  ~ Copyright 2022 Red Hat, Inc. and/or its affiliates.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~       http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

{#if info:isDataIndexAvailable}
<a href="{urlbase}/workflowInstances" class="badge badge-light">
    <i class="fa fa-project-diagram fa-fw"></i>
    Workflow Instances <span id="workflowInstancesCount" class="badge badge-light"/>
</a>
<a href="{urlbase}/monitoring" class="badge badge-light">
    <i class="fa fa-tachometer fa-fw"></i>
    Monitoring
</a>
{/if}
{#if info:isDataIndexAvailable == false}
<p>No Kogito addons detected.</p>
{/if}
{#if info:isDataIndexAvailable}
<script>
    const fillCount = (resourceType) => {
        fetch("{#if config:property('kogito.dev-ui.url')}{config:property('kogito.dev-ui.url')}{#else}http://localhost:{config:property('quarkus.http.port') or '8080'}{/if}/dataindex/" + resourceType + "/count")
                .then(response => response.text())
                .then(count => {
                    document.getElementById(resourceType + "Count").innerText = count;
                }).catch(function () {
            console.log("Error while trying to fetch " + resourceType + " count.");
        });
    };

    fillCount("workflowInstances");
</script>
{/if}
